//
//  MainViewController.swift
//  新浪微博
//
//  Created by guizugulong on 16/1/30.
//  Copyright © 2016年 guizugulong. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    @objc private func plusBtnDidClick(){
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let mainTabbar = MainTabBar()
        setValue(mainTabbar, forKey: "tabBar")
        let actionName = "plusBtnDidClick"
        mainTabbar.plusBtn.addTarget(self, action: Selector(actionName), forControlEvents: .TouchUpInside)

        
        addChildViewControllers()
        
    }
    
    private func addChildViewControllers() {
        
        addChildViewController(HomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileTableViewController(), title: "我", imageName: "tabbar_profile")
        
    }
    
    
    private func addChildViewController(vc: UIViewController,title: String,imageName: String) {
        let nav = UINavigationController(rootViewController: vc)
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
        tabBar.tintColor = UIColor.orangeColor()
        addChildViewController(nav)
    
    }
    
    
    
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
